package smedi.ismedi.mobile.bff.controller.inmail;

import com.smedi.ismedi.inmail.api.dto.request.LoginLogLoginRequest;
import com.smedi.ismedi.inmail.api.dto.request.LoginLogLogoutRequest;
import com.smedi.ismedi.inmail.api.dto.request.LoginLogPageRequest;
import com.smedi.ismedi.inmail.api.dto.response.LoginLogResponse;
import com.smedi.ismedi.inmail.api.feign.RemoteLoginLogFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.smedi.ismedi.inmail.api.constant.ConstantField.ClientTypeEnum.MOBILE;

/**
 * 通知公告Controller
 *
 * @author jiangqinxuan
 * @date 2021/07/26
 */
@Slf4j
@Api(value = "登录日志" , tags = {"登录日志"})
@RequestMapping(value = "/mobilebff/v1/login-log" )
@RestController
@RequiredArgsConstructor
public class LoginLogController {
    private final RemoteLoginLogFeignApi remoteLoginLogFeignApi;

    /**
     * 登录日志-登录
     *
     * @param loginLogLoginRequest 登录日志 登录 请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST" , value = "登录日志-登录" )
    @PostMapping(value = "/login" )
    ResponseData<Long> login(@Validated @RequestBody LoginLogLoginRequest loginLogLoginRequest) {
        loginLogLoginRequest.setClientType(MOBILE.name());
        return remoteLoginLogFeignApi.login(loginLogLoginRequest);
    }

    /**
     * 登录日志-登出
     *
     * @param loginLogLogoutRequest 登录日志 登出 请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST" , value = "登录日志-登出" )
    @PostMapping(value = "/logout" )
    ResponseData<Boolean> logout(@Validated @RequestBody LoginLogLogoutRequest loginLogLogoutRequest) {
        return remoteLoginLogFeignApi.logout(loginLogLogoutRequest);
    }

    /**
     * 登录日志 分页
     *
     * @param loginLogPageRequest 登录日志 分页 请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST" , value = "登录日志-分页" )
    @PostMapping(value = "/page" )
    ResponseData<PaginationData<LoginLogResponse>> page(@Validated @RequestBody LoginLogPageRequest loginLogPageRequest) {
        return remoteLoginLogFeignApi.page(loginLogPageRequest);
    }
}
